#include "stdafx.h"
#include "Progress.h"

ProgressDistrict::ProgressDistrict()
{
}

bool
ProgressDistrict::get(const char& sid, char& data)
{
	iterator it = find(sid);
	if (it==end())
	{
		return false;
	}
	else
	{
		data = it->second;
		return true;
	}
}

char
ProgressDistrict::get(const char& sid)
{
	return (*this)[sid];
}

bool
ProgressDistrict::set(const char& sid, const char& data)
{
	(*this)[sid] = data;
	return true;
}




Progress::Progress()
{
}

ProgressDistrict*
Progress::get(const char& cid, const char& did)
{
	short nKey = cid;
	nKey = (nKey<<8) | did;

	ProgressMap::iterator it = m_flgsMap.find(nKey);
	if (it==m_flgsMap.end())
	{
		return NULL;
	}
	else
	{
		return & it->second;
	}
}

ProgressDistrict*
Progress::add(const char& cid, const char& did)
{
	short nKey = cid;
	nKey = (nKey<<8) | did;
	return & m_flgsMap[nKey];
}

void
Progress::rmv(const char& cid, const char& did)
{
	short nKey = cid;
	nKey = (nKey<<8) | did;
	m_flgsMap.erase(nKey);
}

bool
Progress::set(const char& cid, const char& did, const char& sid, const char& data)
{
	ProgressDistrict* pd = get(cid, did);
	if (pd)
	{
		return pd->set(sid, data);
	}
	else
	{
		return false;
	}
}
